package com.kfm.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

/**
 * @RestController = @Controller + @ResponseBody
 *
 * @Controller中的 handler 方法 return 字符串表示返回 逻辑视图 的名字
 * @ResponseBody 作用是将 handler 方法 返回值转换为字符串
 *
 *
 * @GetMapping() = @RequestMapping(method = "GET")
 * @PostMapping() = @RequestMapping(method = "POST")
 */
@RestController
public class LoginController {

    @RequestMapping(value = "/login", method = {RequestMethod.GET, RequestMethod.PUT})
    public ModelAndView login(){
        // new ModelAndView("逻辑视图名");
        return new ModelAndView("form");
    }

    @PostMapping("/login")
    public String doLogin(String username, String password){
        return "用户名:" + username + ", 密码:" + password;
    }


}
